//
//  SAReturnDocumentsCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/19.
//

#import "SAReturnDocumentsCell.h"
#import "SAInvoiceListModel.h"

@interface SAReturnDocumentsCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UILabel *priceLab;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIImageView *imageV;

@property (nonatomic, strong) UILabel *dateLab;
@property (nonatomic, strong) UILabel *orderNoLab;

@end

@implementation SAReturnDocumentsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAInvoiceListModel *)model {
    _model = model;
    if (model.memberName.length > 0) {
        self.titleLab.text = model.memberName;
    }else {
        self.titleLab.text = @"散客";
    }
    self.dateLab.text = model.salesTime;
    self.orderNoLab.text = model.salesOrderNo;
    self.numLab.text = model.totalCount;
    self.priceLab.text = [NSString stringWithFormat:@"¥%0.2f",[model.actualPrice doubleValue]/100.f];
}

-(void)setReturnModel:(SAInvoiceListModel *)returnModel {
    _returnModel = returnModel;
    if (returnModel.memberName.length > 0) {
        self.titleLab.text = returnModel.memberName;
    }else {
        self.titleLab.text = @"散客";
    }
    self.dateLab.text = returnModel.salesTime;
    self.orderNoLab.text = returnModel.salesOrderNo;
    self.numLab.text = [NSString stringWithFormat:@"x%@",returnModel.totalCount];
    self.priceLab.text = [NSString stringWithFormat:@"¥%0.2f",[returnModel.actualPrice doubleValue]/100.f];
}

-(void)initUI {
    [self.contentView addSubview:self.dateLab];
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.orderNoLab];
    [self.contentView addSubview:self.numLab];
    [self.contentView addSubview:self.priceLab];
    [self.contentView addSubview:self.line];
    [self.contentView addSubview:self.imageV];
}

-(UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] initWithFrame:SARectMake(25, 5, 135, 20)];
        _dateLab.textColor = kBlackColor;
        _dateLab.font = kFont(15);
    }
    return _dateLab;
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(25, 25, 135, 20)];
        _titleLab.textColor = kBlackColor;
        _titleLab.font = kFont(15);
    }
    return _titleLab;
}

-(UILabel *)orderNoLab {
    if (!_orderNoLab) {
        _orderNoLab = [[UILabel alloc] initWithFrame:SARectMake(25, 45, 135, 20)];
        _orderNoLab.textColor = kBlackColor;
        _orderNoLab.font = kFont(15);
    }
    return _orderNoLab;
}

-(UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] initWithFrame:SARectMake(155, 0, 64, 70)];
        _numLab.textColor = kBlackColor;
        _numLab.font = kFont(15);
        _numLab.textAlignment = NSTextAlignmentCenter;
    }
    return _numLab;
}

-(UILabel *)priceLab {
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - kScaleNum(160), 0, kScaleNum(120), kScaleNum(70))];
        _priceLab.textColor = kBlackColor;
        _priceLab.font = kFont(15);
        _priceLab.textAlignment = NSTextAlignmentRight;
    }
    return _priceLab;
}

-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, kScaleNum(70), kScreenWidth, kScaleNum(1))];
        _line.backgroundColor = kLineColor;
    }
    return _line;
}

-(UIImageView *)imageV {
    if (!_imageV) {
        _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth - kScaleNum(35), kScaleNum(24), kScaleNum(22), kScaleNum(22))];
        _imageV.image = [UIImage imageNamed:@"Sale_rightArrow2"];
    }
    return _imageV;
}

@end
